<html>
    <head>

    </head>
    <body>



        <script>
            let d = () =>{
                console.log('111'+this);
            }
            d();

            let myVar2 = 'helloworld'
            let e = {
                myVar1: 'hello!'
                ,
                myVar2//es6引入的简化写法，等同于定义了一个属性"myVar2"：myVar2
                ,
                myFunc1: function diyN(){
                    console.log('rerqe');
                }
                ,
                myFunc2: function diyN(){
                    console.log('dafd');
                }
                ,
                myFunc3(){//es6引入的简化写法，等同于myFunc3:function myfunc3(){}
                    console.log('xcczxv');
                }
            }





            let xiyou = ['唐僧','孙悟空','猪八戒','沙僧'];
            for(let v of xiyou){ //将数组的元素赋值给变量v
                console.log(v);  //通过打印v来打印元素值（注意forin是打印数组下标）
            }


            let object1 = {
                name:'myDiyObj',
                sanguo:['刘备','曹操','孙权'],

                [Symbol.iterator]:function myIterator(){
                    let index = 0;
                    let a= {
                        next:function myDiyNext(){
                            if (0<=index && index<3) {
                                const result = {value:object1.sanguo[index],done:false};
                                index++;
                                return result;
                                
                            } else {
                                return {value:undefined,done:true};
                                
                            };
                        },

                    };
                    return a;
                },
            };

            for (let v of object1) {
                console.log(v);  
            }
            // object1.sanguo.forEach(element => {
            //     console.log(element);
                
            // });


            function* gen(){
                console.log("jieduanyi");
                let y = yield 'jieduan yield';
                console.log('jieduan er');
                console.log(y);
                return y;
            }

            let iterator = gen();
            iterator.next();
            iterator.next('dsafd');

            
            let arr = [1,2,3,3,4,4,5];
            let mySet = new Set(arr);   //使用set集合自动去重
            let myArr = [...mySet]; //使用扩展运算符把集合元素分开，并用中括号再合并成一个数组
            let [myArr2] = [...mySet];  //解构赋值，myArr2等于1
            let [...myArr3] = [...mySet]; //解构赋值，myArr3等于1，2，3，4，5
            let [...myArr4] = [mySet];  //解构赋值，1，2，3，4，5
            console.log(`${myArr}和${myArr2}和${myArr3}  \n${myArr3}`);
            //扩展运算符：所有实现了iterator接口的数据接口都可以通过...变成一个数组
            //结构赋值：等号两边模式相等；




        </script>
    </body>
</html>